﻿using Micro.Extensions.Utilities;
using Micro.Srv.LogCenter.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace Micro.Srv.LogCenter.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class SystemConfigController : ControllerBase
    {
        private readonly ISystemConfigService _systemConfigService;

        public SystemConfigController(ISystemConfigService systemConfigService)
        {
            _systemConfigService = systemConfigService;
        }

        /// <summary>
        /// 添加配置
        /// </summary>
        [HttpPost("AddSystemConfig")]
        public async Task<ComResult<bool>> AddSystemConfig([FromBody] SystemConfigViewModel systemConfig)
        {
            return await _systemConfigService.AddSystemConfigAsync(systemConfig);
        }

        /// <summary>
        /// 获取配置
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetSystemConfigs")]
        public async Task<ComResult<SystemConfigViewModel[]>> GetSystemConfigs(int pageIndex, int pageSize)
        {
            return await _systemConfigService.GetSystemConfigsAsync(pageIndex, pageSize);
        }
    }
}